package com.niit.onlinemusicserver34.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.niit.onlinemusicserver34.common.R;
import com.niit.onlinemusicserver34.mapper.SongListMapper;
import com.niit.onlinemusicserver34.model.domain.SongList;
import com.niit.onlinemusicserver34.model.request.SongListRequest;
import com.niit.onlinemusicserver34.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SongListServiceImpl extends ServiceImpl<SongListMapper, SongList> implements SongListService {

    @Autowired
    SongListMapper songListMapper;
    @Override
    public R listAll() {
        return R.success("查询成功",songListMapper.selectList(null));
    }

    @Override
    public R saveSongList(SongListRequest songListRequest) {
        return R.success("添加成功",songListMapper.insert(songListRequest));
    }

    @Override
    public R deleteSongList(Integer id) {
        return R.success("删除成功",songListMapper.deleteById(id));
    }

    @Override
    public R updateSongList(SongListRequest songListRequest) {
        return R.success("更新成功",songListMapper.updateById(songListRequest));
    }

    @Override
    public R getSongListStyleData() {
        return R.success("查询成功",songListMapper.getSongListStyleData());
    }

    @Override
    public R likeTitle(String title) {
        QueryWrapper<SongList> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("title",title);
        return R.success(null, songListMapper.selectList(queryWrapper));
    }

    @Override
    public R likeStyle(String style) {
        QueryWrapper<SongList> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("style",style);
        return R.success(null, songListMapper.selectList(queryWrapper));
    }
}
